#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_rgb.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_lcd_touch_gt911.h"

#include "driver/spi_common.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "driver/i2c.h"

#include "lvgl.h"
#include "lv_demos.h"

#include "demo_app.h"

#define PIN_NUM_MOSI (GPIO_NUM_4)
#define PIN_NUM_CLK (GPIO_NUM_5)
#define PIN_NUM_CS (GPIO_NUM_6)
#define LCD_HOST SPI2_HOST

#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (16 * 1000 * 1000)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_BK_LIGHT 42
#define EXAMPLE_PIN_NUM_HSYNC 48
#define EXAMPLE_PIN_NUM_VSYNC 45
#define EXAMPLE_PIN_NUM_DE 21
#define EXAMPLE_PIN_NUM_PCLK 47
#define EXAMPLE_PIN_NUM_DATA0 14  // B0
#define EXAMPLE_PIN_NUM_DATA1 13  // B1
#define EXAMPLE_PIN_NUM_DATA2 12  // B2
#define EXAMPLE_PIN_NUM_DATA3 11  // B3
#define EXAMPLE_PIN_NUM_DATA4 10  // B4
#define EXAMPLE_PIN_NUM_DATA5 9   // G0
#define EXAMPLE_PIN_NUM_DATA6 46  // G1
#define EXAMPLE_PIN_NUM_DATA7 3   // G2
#define EXAMPLE_PIN_NUM_DATA8 8   // G3
#define EXAMPLE_PIN_NUM_DATA9 18  // G4
#define EXAMPLE_PIN_NUM_DATA10 17 // G5
#define EXAMPLE_PIN_NUM_DATA11 16 // R0
#define EXAMPLE_PIN_NUM_DATA12 15 // R1
#define EXAMPLE_PIN_NUM_DATA13 7  // R2
#define EXAMPLE_PIN_NUM_DATA14 5  // R3
#define EXAMPLE_PIN_NUM_DATA15 4  // R4
#define EXAMPLE_PIN_NUM_DISP_EN -1

// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 480
#define EXAMPLE_LCD_V_RES 854

#define EXAMPLE_LVGL_TICK_PERIOD_MS 2

void guiTask(void *pvParameters);